//
//  AuthenMiniMsgModel.swift
//  kxf
//
//  Created by Mac on 2024/3/7.
//

import Foundation

class AuthenMiniMsgModel {
    
    //主键
    var tel = ""
    var posChannel = "ys"
    var merchantType = "1"
    var photoImgUrlMentou = ""
    var photoImgUrlDianNei = ""
    var photoImgUrlCash   = ""
    var photoImgUrlLocation   = ""
    var photoImgUrlIdCardFront = ""
    var photoImgUrlIdCardBack  = ""
    var photoImgUrlIdCardInhand = ""
    var photoImgUrlBankCardFront = ""
    
    var mercNameAll = ""
    var mercNameSimple = ""
    var mercMccCode    = ""
    var mercMccName = ""
    var mercAlipayMccCode = ""
    var mercAlipayMccName = ""
    var mercAlipayMcc = ""
    var mercWeChatMccCode = ""
    var mercWeChatMccName = ""
    var mercWeChatMcc = ""
    var addressName = ""
    var addressDetail = ""
    var emailAddress = ""
    var remark  = ""
    
    var legalName = ""
    var legalIdCardNo = ""
    var legalIdCardStartTime = ""
    var legalIdCardEndTime = ""
    var legalAddress = ""
    var legalBankName = ""
    var legalBankBranchCode = ""
    var legalBankBranchName = ""
    var legalBankNo   = ""
    var legalBankPhone = ""
    var accBankTypeText = "对私账户" // 1对公   2对私
    
    var addressProvinceCode = ""
    var addressProvinceName = ""
    var addressCityCode = ""
    var addressCityName = ""
    var addressAreaCode = ""
    var addressAreaName = ""
    var placeCode = ""
    var placeCodeText = ""
    
    static let shareInstance = AuthenMiniMsgModel()
    
    private init(){
        
    }
    
    func dealAddressToPlaceCode() {
        self.addressProvinceName = AddressModel.shareInstance.addressProvinceName
        self.addressProvinceCode = AddressModel.shareInstance.addressProvinceCode
        self.addressCityName = AddressModel.shareInstance.addressCityName
        self.addressCityCode = AddressModel.shareInstance.addressCityCode
        self.addressAreaCode = AddressModel.shareInstance.addressAreaCode
        self.addressAreaName = AddressModel.shareInstance.addressAreaName
        
        self.placeCode = "\(self.addressProvinceName)\(self.addressCityName)\(self.addressAreaName)_\(self.addressProvinceCode)_\(self.addressCityCode)_\(self.addressAreaCode)"
        self.placeCodeText = "\(self.addressProvinceName)\(self.addressCityName)\(self.addressAreaName)"
    }
    func clearAddressMsg(){
        self.addressProvinceName = ""
        self.addressProvinceCode = ""
        self.addressCityName = ""
        self.addressCityCode = ""
        self.addressAreaName = ""
        self.addressCityCode = ""
    }
    
    func refreshMsg(dict:NSDictionary) {
        self.tel = dict["tel"]as? String ?? ""
        self.posChannel = dict["posChannel"]as? String ?? ""
        self.photoImgUrlMentou = dict["shopHeadPic"]as? String ?? ""
        self.photoImgUrlDianNei = dict["shopOnPic"]as? String ?? ""
        self.photoImgUrlCash = dict["shopCashPic"]as? String ?? ""
        self.photoImgUrlLocation = dict["otherAttachment"]as? String ?? ""
        self.mercNameAll = dict["mchName"]as? String ?? ""
        self.mercNameSimple = dict["name"]as? String ?? ""
        self.mercMccCode = dict["mcc"]as? String ?? ""
        self.mercMccName = dict["industryTypeOne"]as? String ?? ""
        self.mercWeChatMcc = dict["wechatMcc"]as? String ?? ""
        self.mercAlipayMcc = dict["aliPayMcc"]as? String ?? ""
        self.placeCode = dict["placeCode"]as? String ?? ""
        self.legalBankPhone = dict["bankTel"]as? String ?? ""
        self.addressDetail = dict["merchantAddress"]as? String ?? ""
        self.legalName = dict["xinming"]as? String ?? ""
        self.emailAddress = dict["email"]as? String ?? ""
        self.remark = dict["remark"]as? String ?? ""
        self.legalBankName = dict["bankName"]as? String ?? ""
        self.photoImgUrlIdCardFront = dict["shenfengzhengpic"]as? String ?? ""
        self.photoImgUrlIdCardBack = dict["shenfengfanpic"]as? String ?? ""
        self.photoImgUrlIdCardInhand = dict["holdingCardPic"]as? String ?? ""
        self.legalIdCardNo = dict["shenfengid"]as? String ?? ""
        self.legalIdCardStartTime = dict["shenfengbegindate"]as? String ?? ""
        self.legalIdCardEndTime = dict["shenfengenddate"]as? String ?? ""
        self.legalAddress = dict["lawyerAddress"]as? String ?? ""
        self.photoImgUrlBankCardFront = dict["bankcardpic"]as? String ?? ""
        self.legalBankNo = dict["bankcardid"]as? String ?? ""
        self.legalBankBranchName = dict["openingBank"]as? String ?? ""
        self.legalBankBranchCode = dict["branchBankNo"]as? String ?? ""
        
        let placeCode = dict["placeCode"]as? String ?? ""
        let placeArr = placeCode.components(separatedBy: "_")
        
        if placeArr.count >= 1{
            self.placeCodeText = placeArr[0]
        }
        
        let alipayMccArr = self.mercAlipayMcc.components(separatedBy: "_")
        if alipayMccArr.count >= 1{
            self.mercAlipayMccName = alipayMccArr[0]
        }
        
        let wechatArr = self.mercWeChatMcc.components(separatedBy: "_")
        if wechatArr.count >= 1{
            self.mercWeChatMccName = wechatArr[0]
        }
    }
    
    func clearMsg() {
        self.photoImgUrlMentou = ""
        self.photoImgUrlDianNei = ""
        self.photoImgUrlCash = ""
        self.photoImgUrlLocation = ""
        self.mercNameAll = ""
        self.mercNameSimple = ""
        self.mercMccCode = ""
        self.mercMccName = ""
        self.mercWeChatMcc = ""
        self.mercWeChatMccName = ""
        self.mercWeChatMccCode = ""
        self.mercAlipayMccName = ""
        self.mercAlipayMccCode = ""
        self.mercAlipayMcc = ""
        self.placeCode = ""
        self.placeCodeText = ""
        self.legalBankPhone = ""
        self.addressDetail = ""
        self.legalName = ""
        self.emailAddress = ""
        self.remark = ""
        self.legalBankName = ""
        self.legalBankBranchCode = ""
        self.photoImgUrlIdCardFront = ""
        self.photoImgUrlIdCardBack = ""
        self.photoImgUrlIdCardInhand = ""
        self.legalIdCardNo = ""
        self.legalIdCardStartTime = ""
        self.legalIdCardEndTime = ""
        self.legalAddress = ""
        self.photoImgUrlBankCardFront = ""
        self.legalBankNo = ""
    }
}


